package com.atkxp.dao.impl;

import com.atkxp.dao.OrderItemDao;
import com.atkxp.domain.Order;
import com.atkxp.domain.OrderItem;

import java.util.List;

/**
 * @author user
 * @declaration
 * @create 2022/10/5-10:06
 */
public class OrderItemDaoImpl extends BaseDao<OrderItem> implements OrderItemDao {
    @Override
    public int saveOrderItem(OrderItem orderItem) {
        String sql = "insert into t_order_item(name, count, price, total_price, order_id) values(?, ?, ?, ?, ?)";
        return update(sql, orderItem.getName(), orderItem.getCount(), orderItem.getPrice(), orderItem.getTotal_price(), orderItem.getOrder_id());
    }

    @Override
    public List<OrderItem> queryOrderItemsByOrderId(String orderId) {
        String sql = "select * from t_order_item where order_id = ?";
        return getAllInstance(sql, orderId);
    }
}
